#pragma once

#include <vector>
#include <set>

class Instruction;

///
/// @brief IR基本块
///
class BasicBlock {
public:
    // 构造函数
    BasicBlock() = default;

    // 添加指令
    void addInstruction(Instruction * inst)
    {
        instructions.push_back(inst);
    }

    // 获取指令列表
    std::vector<Instruction *> & getInstructions()
    {
        return instructions;
    }

    // 添加后继基本块
    void addSuccessor(BasicBlock * succ)
    {
        successors.insert(succ);
    }

    // 获取后继基本块
    const std::set<BasicBlock *> & getSuccessors() const
    {
        return successors;
    }

private:
    std::vector<Instruction *> instructions;
    std::set<BasicBlock *> successors;
};
